<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<!doctype html>
<html>
<head>
    <%@ include file="/common/common.jsp" %>
    <title>我的收款码</title>
    <link rel="stylesheet" type="text/css" href="../statics/aui/css/aui.css"/>
    <link rel="stylesheet" type="text/css" href="${ctx }/css/weui.min.css"/>
</head>
<body>
<section class="aui-content">
    <ul class="aui-list">
        <table width="100%">
            <c:forEach items="${requestScope.cashList}" var="u">
                <tr>
                	<td>
                		 <li class="aui-list-item ">
                		 	<div class="aui-list-item-inner">
                		 		<label style="font-size: 0.6rem;color: #757575;width: 50px;">${u.name}</label>
                		 		<table  cellspacing="0" cellpadding="0">
                		 			<c:if test="${u.codeList == null}">
                                		<label style="font-size: 0.6rem;color: #757575;">暂无二维码</label>
                                	</c:if>
              		 				<c:forEach items="${u.codeList}" var="c"> 
              		 				<tr>
	               		 				<td>
	               		 				<li  class="aui-list-item " >
	               		 				<%-- <li  class="aui-list-item " style="<c:if test="${c.codeStatus==0}">background-color: rgba(133,119,129,0.54)</c:if>"> --%>
	               		 					<div align="left" class="aui-list-item-inner qrCodeDiv" codeStatus="${c.codeStatus}" codeno="${c.codeNo}" codeName="${c.codeName}" style="width: 280px;">
				                                <div align="left" class="aui-list-item-title receivables_text " >
				                                        ${c.codeName}<label style="font-size: 0.6rem;color: #757575;">(${c.shopname})</label>
				                                	
				                                </div>
				                                <c:if test="${c.codeName == null}">
				                                
				                                </c:if>
				                                <div class="aui-list-item-right" >${c.codeNo}</div>
				                            </div>
	               		 				</li>
	               		 				 <%-- <label style="font-size: 0.6rem;color: #757575;">${c.codeName}</label> --%>
	               		 				</td>
	               		 			</tr>
              		 				</c:forEach>
                		 		</table>
                		 	</div>
                		 </li>
                	</td>
                    <td>
                    	
                       <%--  <li class="aui-list-item " style="<c:if test="${u.codeStatus==0}">background-color: rgba(133,119,129,0.54)</c:if>">
                            <div class="aui-list-item-inner">
                                <div class="aui-list-item-title receivables_text qrCodeDiv" codeStatus="${u.codeStatus}" codeno="${u.codeNo}" codeName="${u.codeName}">
                                        ${u.codeName}<label style="font-size: 0.6rem;color: #757575;">(${u.shopname})</label>
                                </div>
                                <div class="aui-list-item-right" title="${u.bankId}">${u.codeNo}</div>
                            </div>
                        </li> --%>
                    </td>
                </tr>
            </c:forEach>
        </table>
    </ul>
</section>
<section class="aui-content"
         style="margin-top: 44px; padding-left: 20px; padding-right: 20px;">
    <p>
        <c:if test="${role==1}">
        <c:if test="${showAddBut}">
    <div class="aui-btn aui-btn-info  aui-btn-block" onclick="location='qrCodePage'">添加收款码</div>
    </c:if>
    </c:if>
    <c:if test="${!showAddBut}">
        <div class="aui-btn aui-btn-info  aui-btn-block" onclick="showMessage();">添加收款码</div>
    </c:if>
    <br/>
    </p>
</section>
<c:if test="${message!='' && message!=null}">
    <div class="page">
        <div class="weui-msg">
            <div class="weui-msg__icon-area"><i class="weui-icon-warn weui-icon_msg-primary"></i></div>
            <div class="weui-msg__text-area">
                <h2 class="weui-msg__title">提示</h2>
                <p class="weui-msg__desc">${message}</p>
            </div>
        </div>
    </div>
</c:if>
<!------弹层处理------><!------弹层处理------>
<div>
    <div class="weui-mask" id="iosMask" style="display: none"></div>
    <div class="weui-actionsheet" id="iosActionsheet">
        <div class="weui-actionsheet__title">
            <input type="hidden" id="codeno">
            <input type="hidden" id="codeName">
            <p class="weui-actionsheet__title-text">选择操作</p>
        </div>
        <div class="weui-actionsheet__menu">
            <div class="weui-actionsheet__cell colorPrimary">详情</div>
            <div class="weui-actionsheet__cell colorDanger">删除</div>
        </div>
        <div class="weui-actionsheet__action">
            <div class="weui-actionsheet__cell" id="iosActionsheetCancel">取消</div>
        </div>
    </div>
</div>

<div>
    <div class="weui-mask" id="iosNdMask" style="display: none"></div>
    <div class="weui-actionsheet" id="iosNdActionsheet">
        <div class="weui-actionsheet__title">
            <input type="hidden" id="codenoNd">
            <p class="weui-actionsheet__title-text">选择操作</p>
        </div>
        <div class="weui-actionsheet__menu">
            <div class="weui-actionsheet__cell colorPrimary">详情</div>
        </div>
        <div class="weui-actionsheet__action">
            <div class="weui-actionsheet__cell" id="iosNdActionsheetCancel">取消</div>
        </div>
    </div>
</div>
<div id="dialogs">
    <div class="js_dialog" id="iosDialog1" style="display: none;">
        <div class="weui-mask">
            <input type="hidden" id="codenoDelete">
        </div>
        <div class="weui-dialog">
            <div class="weui-dialog__hd"><strong class="weui-dialog__title">确认要删除？</strong></div>
            <div class="weui-dialog__bd">确定要删除 <label id="codeNameVal"></label> 的收款二维码吗？</div>
            <div class="weui-dialog__ft">
                <a href="javascript:;" class="weui-dialog__btn weui-dialog__btn_default DeleteDefault">取消</a>
                <a href="javascript:;" class="weui-dialog__btn weui-dialog__btn_primary DeleteDetermine">确定</a>
            </div>
        </div>
    </div>
</div>
<!------弹层处理------><!------弹层处理------>

<div id="dialogs">
    <div class="js_dialog" id="iosDialog2" style="display: none;">
        <div class="weui-mask"></div>
        <div class="weui-dialog">
            <div class="weui-dialog__bd" id="DialogMessage"></div>
            <div class="weui-dialog__ft">
                <a href="javascript:;" class="weui-dialog__btn weui-dialog__btn_primary DeleteDefault">确定</a>
            </div>
        </div>
    </div>
</div>

<script type="application/javascript">

	var $iosDialog2 = $('#iosDialog2');
	$('#dialogs').on('click', '.DeleteDefault', function () { //取消按钮事件
	    $(this).parents('.js_dialog').fadeOut(200);
	});
	
	function showMessage(){
		$("#DialogMessage").html("收款配置信息错误，请联系管理员设置");
	    $iosDialog2.fadeIn(200);
	}

    var role = "${role}";
    $(function(){
        //------有删除弹层--------
        var $iosActionsheet = $('#iosActionsheet');//有删除弹层
        var $iosMask = $('#iosMask');
        function hideActionSheets() {
            $iosActionsheet.removeClass('weui-actionsheet_toggle');
            $iosMask.fadeOut(200);
        }
        $iosMask.on('click', hideActionSheets);
        $('#iosActionsheetCancel').on('click', hideActionSheets);

        //-----无删除弹层-------
        var $iosNdActionsheet = $('#iosNdActionsheet');//无删除弹层
        var $iosNdMask = $('#iosNdMask');
        function hideNdActionSheet() {
            $iosNdActionsheet.removeClass('weui-actionsheet_toggle');
            $iosNdMask.fadeOut(200);
        }
        $iosNdMask.on('click', hideNdActionSheet);
        $('#iosNdActionsheetCancel').on('click', hideNdActionSheet);

        $(".qrCodeDiv").on("click", function(){
            var codeno = $(this).attr("codeno");
            var codeName = $(this).attr("codeName");
            var codeStatus = $(this).attr("codeStatus");
            if (role==1&&codeStatus!=0) {
                $iosActionsheet.addClass('weui-actionsheet_toggle');
                $iosMask.fadeIn(200);
                $("#codeno").val(codeno);
                $("#codeName").val(codeName);
            }else{
                $iosNdActionsheet.addClass('weui-actionsheet_toggle');
                $iosNdMask.fadeIn(200);
                $("#codenoNd").val(codeno);
            }
        });

        //详情
        $(".colorPrimary").on("click", function(){
            var codeno = $("#codeno").val();
            if(codeno==""||codeno==null){
                codeno = $("#codenoNd").val();
            }
            location = 'viewCodeDetails?codeNo=' + codeno;
        });
        //删除
        $(".colorDanger").on("click", function(){
            var codeno = $("#codeno").val();
            var codeName = $("#codeName").val();
            hideActionSheets();

            $("#codeNameVal").html(codeName);
            $("#codenoDelete").val(codeno);
            $iosDialog1.fadeIn(200);
        });

        //-------确定+取消弹层------
        var $iosDialog1 = $('#iosDialog1');
        $('#dialogs').on('click', '.DeleteDefault', function(){ //取消按钮事件
            $(this).parents('.js_dialog').fadeOut(200);
        });
        $('#dialogs').on('click', '.DeleteDetermine', function(){ //确定按钮事件
            var codeno = $("#codenoDelete").val();
            $.ajax({
                type: "POST",
                url: "../auth/deleteQrCode",
                data: {codeNo: codeno},
                dataType: "json",
                success: function (result) {
                    if (result.code == 0) {
                        location.href = "../auth/viewQRCode";
                    } else {
                        $.toast(result.msg, "cancel");
                    }
                }
            });
        });

    });

</script>
</body>
</html>